<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
	function ShowAttachMail(MAILCODE,DOCNUMBER,DBDSN,FORMCODE) {
		window.open("../../webshell/mailcreator/templates/eFormAttach.cfm?mailcode=" + MAILCODE + "&" +  DOCNUMBER + "&DBDSN=" + DBDSN + "&FORMCODE=" + FORMCODE,"Forms", "width=700,height=530,ScrollBars=Yes,Resizable=Yes");
	}
</SCRIPT>
<cfif ISDEFINED("URL.PAGE")>
	<CFSET table_dsn="#dsnMaster#">
</CFIF>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=3 WIDTH="100%" BGCOLOR="#FFFFFF">
	<TR><TD height="3px"></TD></TR>
	<TR>
	<CFIF IsDefined("url.view") OR IsDefined("url.print") OR IsDefined("url.route") OR IsDefined("url.EDIT") OR IsDefined("url.replicate")>
		<TD>
		<CFIF isDefined("GetForm.ATTACHEDMAIL")>
			<CFIF UCase(Getform.ATTACHEDMAIL) NEQ "" or UCase(Getform.ATTACHEDMAIL) NEQ "[NULL]">
				<CFQUERY NAME="qryMailAttach" DATASOURCE="#client.global_dsn#">
					SELECT MAILCODE, DESCRIPTION
					FROM EGRGEMAILTEMPLATES
					WHERE COMPANYCODE_FK = '#client.companycode#' AND MAILCODE='#Getform.ATTACHEDMAIL#'
					ORDER BY DESCRIPTION, MAILCODE
				</CFQUERY>
				<cfif ISDEFINED("URL.ROUTE")>
					<CFQUERY NAME="GetRecord" DATASOURCE="#client.company_dsn#">
						SELECT R.*, M.TABLENAME_FK, M.DESCRIPTION, M.PRIORITY, M.ORGENTITY, M.INCLUDEEFORM, M.ROUTEPARAMS
						FROM CRGROUTERECORDS R, CRGROUTEMAIN M
						WHERE
							(R.ROUTEID = M.ROUTEID) AND
							(RECORDID  = '#url.id#')<!--- AND
							(R.ISHIDE    = 'N')--->
					</CFQUERY>
					<CFIF GetRecord.RECORDCOUNT>
						<CFQUERY NAME="GetEntry" DATASOURCE="#table_dsn#">
							SELECT *
							FROM #GetRecord.TABLENAME_FK#
							WHERE
								(ROUTEID = '#GetRecord.ROUTEID#')
						</CFQUERY>
						<CFSET theURL= "ROUTEID=" & "#GetRecord.ROUTEID#">
					</CFIF>
				<cfelse>
					<CFIF NOT ISDEFINED("FORM.ADD")>
						<CFIF ISDEFINED("URL.PAGE")>
							<CFQUERY NAME="GetEntry" DATASOURCE="#dsnMaster#" MAXROWS=1>
								SELECT *
								FROM #GetForm.TABLENAME_FK#
								WHERE
									<!--- changed client.chapa to pidno variable  --->
									(PERSONNELIDNO = '#pidno#')
									<CFSET theURL= "">
									<CFLOOP  INDEX="x" FROM="1" TO="5">
										<CFSET temp = evaluate("GetForm.PK_FIELD" & x)>
										<CFIF temp NEQ "">
											<CFSET theVal = decrypt(evaluate("url.key#x#"),client.ek)>
											AND (#ucase(temp)# = '#theVaL#')
											<CFIF theURL EQ "">
												<CFSET theURL= #ucase(evaluate("GetForm.PK_FIELD" & x))# & "=" & #theVal#>
											<CFELSE>
												<CFSET theURL= theURL & "&" & #ucase(evaluate("GetForm.PK_FIELD" & x))# & "=" & #theVal#>
											</CFIF>
										</CFIF>
									</CFLOOP>
							</CFQUERY>
		
						<CFELSE>
							<CFQUERY NAME="GetEntry" DATASOURCE="#table_dsn#" MAXROWS=1>
								SELECT *
								FROM #GetForm.TABLENAME_FK#
								WHERE
									<!--- changed client.chapa to pidno variable  --->
									(PERSONNELIDNO = '#pidno#')
									<CFSET theURL= "">
									<CFLOOP  INDEX="x" FROM="1" TO="5">
										<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
											<CFSET theVal = evaluate("url." & evaluate("GetForm.PK_FIELD" & x))>
											AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
											<CFIF theURL EQ "">
												<CFSET theURL= #ucase(evaluate("GetForm.PK_FIELD" & x))# & "=" & #theVal#>
											<CFELSE>
												<CFSET theURL= theURL & "&" & #ucase(evaluate("GetForm.PK_FIELD" & x))# & "=" & #theVal#>
											</CFIF>
										</CFIF>
									</CFLOOP>
							</CFQUERY>
						</CFIF>
					</CFIF>
				</cfif>
		
				<CFIF qryMailAttach.RecordCount AND GETENTRY.RECORDCOUNT>
					<B><U>Mail Attachments</U>:</B>	
					<BR>
					<CFOUTPUT QUERY="qryMailAttach">
					<!--- 	Disable link & checkbox if file not exist...
						...and hide checkbox if form is for viewing, printing or route only - winston --->
					
						<IMG SRC="#client.icon_path#message.gif"><A HREF="javascript:void(0);" onClick="javascript:ShowAttachMail('#MAILCODE#','#theURL#','#table_dsn#','#GETFORM.FORMCODE#')" CLASS="regular11">#DESCRIPTION#</A>&nbsp;
					</CFOUTPUT>
				</CFIF>	
			</CFIF>
	<CFELSEIF isDefined("GetFrmDtl.ATTACHEDMAIL")>
		<CFIF UCase(GetFrmDtl.ATTACHEDMAIL) NEQ "" or UCase(GetFrmDtl.ATTACHEDMAIL) NEQ "[NULL]">
			<CFQUERY NAME="qryMailAttach" DATASOURCE="#client.global_dsn#">
				SELECT MAILCODE, DESCRIPTION
				FROM EGRGEMAILTEMPLATES
				WHERE COMPANYCODE_FK = '#client.companycode#' AND MAILCODE='#GetFrmDtl.ATTACHEDMAIL#'
				ORDER BY DESCRIPTION, MAILCODE
			</CFQUERY>
			<cfif ISDEFINED("URL.ROUTE")>
				<CFQUERY NAME="GetRecord" DATASOURCE="#client.company_dsn#">
					SELECT R.*, M.TABLENAME_FK, M.DESCRIPTION, M.PRIORITY, M.ORGENTITY, M.INCLUDEEFORM, M.ROUTEPARAMS
					FROM CRGROUTERECORDS R, CRGROUTEMAIN M
					WHERE
						(R.ROUTEID = M.ROUTEID) AND
						(RECORDID  = '#url.id#') AND
						(R.ISHIDE    = 'N')
				</CFQUERY>
				<CFIF GetRecord.RECORDCOUNT>
					<CFQUERY NAME="GetEntry" DATASOURCE="#table_dsn#">
						SELECT *
						FROM #GetFrmDtl.DETAILTABLE#
						WHERE
							(ROUTEID = '#GetRecord.ROUTEID#')
					</CFQUERY>
					<CFSET theURL= "ROUTEID=" & "#GetRecord.ROUTEID#">
				</CFIF>
			<cfelse>
				<CFIF NOT ISDEFINED("FORM.ADD")>
					<CFIF ISDEFINED("URL.PAGE")>
						<CFQUERY NAME="GetEntry" DATASOURCE="#dsnMaster#" MAXROWS=1>
							SELECT *
							FROM #GetFrmDtl.DETAILTABLE#
							WHERE
								<!--- changed client.chapa to pidno variable  --->
								(PERSONNELIDNO = '#pidno#')
								<CFSET theURL= "">
								<CFLOOP  INDEX="x" FROM="1" TO="5">
									<CFSET temp = evaluate("GetFrmDtl.DTL_FIELD" & x)>
									<CFIF temp NEQ "">
										<CFSET theVal = decrypt(evaluate("url.key#x#"),client.ek)>
										AND (#ucase(temp)# = '#theVaL#')
										<CFIF theURL EQ "">
											<CFSET theURL= #ucase(evaluate("GetFrmDtl.DTL_FIELD" & x))# & "=" & #theVal#>
										<CFELSE>
											<CFSET theURL= theURL & "&" & #ucase(evaluate("GetFrmDtl.DTL_FIELD" & x))# & "=" & #theVal#>
										</CFIF>
									</CFIF>
								</CFLOOP>
						</CFQUERY>
	
					<CFELSE>
						<CFQUERY NAME="GetEntry" DATASOURCE="#table_dsn#" MAXROWS=1>
							SELECT *
							FROM #GetFrmDtl.DETAILTABLE#
							WHERE
								<!--- changed client.chapa to pidno variable  --->
								(PERSONNELIDNO = '#pidno#')
								<CFSET theURL= "">
								<CFLOOP  INDEX="x" FROM="1" TO="5">
									<CFIF evaluate("GetFrmDtl.DTL_FIELD" & x) NEQ "">
										<CFSET theVal = evaluate("url." & evaluate("GetFrmDtl.DTL_FIELD" & x))>
										AND (#ucase(evaluate("GetFrmDtl.DTL_FIELD" & x))# = '#theVal#')
										<CFIF theURL EQ "">
											<CFSET theURL= #ucase(evaluate("GetFrmDtl.DTL_FIELD" & x))# & "=" & #theVal#>
										<CFELSE>
											<CFSET theURL= theURL & "&" & #ucase(evaluate("GetFrmDtl.DTL_FIELD" & x))# & "=" & #theVal#>
										</CFIF>
									</CFIF>
								</CFLOOP>
						</CFQUERY>
					</CFIF>
				</CFIF>
			</cfif>
	
			<CFIF qryMailAttach.RecordCount AND GETENTRY.RECORDCOUNT>
				<B><U>Mail Attachments</U>:</B>	
				<BR>
				<CFOUTPUT QUERY="qryMailAttach">
				<!--- 	Disable link & checkbox if file not exist...
					...and hide checkbox if form is for viewing, printing or route only - winston --->
				
					<IMG SRC="#client.icon_path#message.gif"><A HREF="javascript:void(0);" onClick="javascript:ShowAttachMail('#MAILCODE#','#theURL#','#table_dsn#','#GETFORM.FORMCODE#')" CLASS="regular11">#DESCRIPTION#</A>&nbsp;
				</CFOUTPUT>
			</CFIF>		
		</CFIF>
	</CFIF>	
	<TD>
	<CFIF (isDefined("Getform.ENABLEATTACHMENTS") AND UCase(Getform.ENABLEATTACHMENTS) IS "Y" AND
		IsDefined("GetEntry.ATTACHMENTCODE") AND
		GetEntry.ATTACHMENTCODE NEQ "") OR 
		(isDefined("GetFrmDtl.ENABLEATTACHMENTS") AND UCase(GetFrmDtl.ENABLEATTACHMENTS) IS "Y" AND
		IsDefined("GetEntry.ATTACHMENTCODE") AND
		GetEntry.ATTACHMENTCODE NEQ "")>
		<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE=#client.company_dsn#>
			SELECT *
			FROM ECINFORMSATTACH
			WHERE ATTACHMENTCODE = '#GetEntry.ATTACHMENTCODE#'
		</CFQUERY>
	
		<CFIF qryECINFORMSATTACH.RecordCount>
			<CFIF IsDefined("url.view") OR IsDefined("url.print") OR IsDefined("url.route") OR IsDefined("url.isread")>
				<B><U>File Attachments</U>:</B>
			<CFELSE>
				<B><U>File Attachments (<i>check the box to remove attachment</i>)</U>:</B>
			</CFIF>
			<BR>
			<CFOUTPUT QUERY="qryECINFORMSATTACH">
				
				<!--- 	Disable link & checkbox if file not exist...
					...and hide checkbox if form is for viewing, printing or route only - winston --->
				<CFIF IsDefined("url.view") OR IsDefined("url.print") OR IsDefined("url.route") OR IsDefined("url.isread")>
				<!--- Filename searched Old - Attachment Code
				<CFIF FileExists("#ExpandPath(client.attachment_path)##qryECINFORMSATTACH.ATTACHFILECODE#.#ListLast(qryECINFORMSATTACH.DESCRIPTION, '.')#")> --->
				<!--- File name Description instead of Attachment Code --->
					<CFIF FileExists("#ExpandPath(client.attachment_path)##qryECINFORMSATTACH.DESCRIPTION#")>
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;<A HREF="###CreateUUID()#" onclick="eAttachmentHandle=window.open('#client.attachment_path##qryECINFORMSATTACH.DESCRIPTION#', '', 'location=no,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100)); eAttachmentHandle.moveTo(0,0); sTitle='#JSStringFormat(qryECINFORMSATTACH.DESCRIPTION)#'; setTimeout('ChangeTitle(sTitle, eAttachmentHandle)', 1000);" CLASS="regular11">#qryECINFORMSATTACH.DESCRIPTION#</A>
					<CFELSEIF FileExists("#ExpandPath(client.attachment_path)##qryECINFORMSATTACH.ATTACHFILECODE#.#ListLast(qryECINFORMSATTACH.DESCRIPTION, '.')#")>
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;<A HREF="###CreateUUID()#" onclick="eAttachmentHandle=window.open('#client.attachment_path##qryECINFORMSATTACH.ATTACHFILECODE#.#ListLast(qryECINFORMSATTACH.DESCRIPTION, '.')#', '', 'location=no,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100)); eAttachmentHandle.moveTo(0,0); sTitle='#JSStringFormat(qryECINFORMSATTACH.DESCRIPTION)#'; setTimeout('ChangeTitle(sTitle, eAttachmentHandle)', 1000);" CLASS="regular11">#qryECINFORMSATTACH.DESCRIPTION#</A>
					<CFELSE>
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;#qryECINFORMSATTACH.DESCRIPTION#&nbsp;(File not Exist)
					</CFIF>
				<CFELSE>
					<CFIF FileExists("#ExpandPath(client.attachment_path)##qryECINFORMSATTACH.DESCRIPTION#")>
						&nbsp;&nbsp;<INPUT CLASS="regular11" TYPE="CheckBox" NAME="chkDelFileAtt#CurrentRow#" VALUE="#qryECINFORMSATTACH.ATTACHFILECODE#">
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;<A HREF="###CreateUUID()#" onclick="eAttachmentHandle=window.open('#client.attachment_path##qryECINFORMSATTACH.DESCRIPTION#', '', 'location=no,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100)); eAttachmentHandle.moveTo(0,0); sTitle='#JSStringFormat(qryECINFORMSATTACH.DESCRIPTION)#'; setTimeout('ChangeTitle(sTitle, eAttachmentHandle)', 1000);" CLASS="regular11">#qryECINFORMSATTACH.DESCRIPTION#</A>
					<CFELSEIF FileExists("#ExpandPath(client.attachment_path)##qryECINFORMSATTACH.ATTACHFILECODE#.#ListLast(qryECINFORMSATTACH.DESCRIPTION, '.')#")>
						&nbsp;&nbsp;<INPUT CLASS="regular11" TYPE="CheckBox" NAME="chkDelFileAtt#CurrentRow#" VALUE="#qryECINFORMSATTACH.ATTACHFILECODE#">
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;<A HREF="###CreateUUID()#" onclick="eAttachmentHandle=window.open('#client.attachment_path##qryECINFORMSATTACH.ATTACHFILECODE#.#ListLast(qryECINFORMSATTACH.DESCRIPTION, '.')#', '', 'location=no,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + (window.screen.availWidth - 100) + ',height=' + (window.screen.availHeight - 100)); eAttachmentHandle.moveTo(0,0); sTitle='#JSStringFormat(qryECINFORMSATTACH.DESCRIPTION)#'; setTimeout('ChangeTitle(sTitle, eAttachmentHandle)', 1000);" CLASS="regular11">#qryECINFORMSATTACH.DESCRIPTION#</A>
					<CFELSE>
						&nbsp;&nbsp;<INPUT CLASS="regular11" TYPE="CheckBox" NAME="chkDelFileAtt#CurrentRow#" VALUE="#qryECINFORMSATTACH.ATTACHFILECODE#" DISABLED>
						&nbsp;<IMG SRC="#client.icon_path#message.gif">&nbsp;#qryECINFORMSATTACH.DESCRIPTION#&nbsp;(File not Exist)
					</CFIF>
				</CFIF>	
			</CFOUTPUT>
		</CFIF>
	</CFIF>
	<CFIF (isDefined("Getform.ATTACHEDLINK") AND UCase(Getform.ATTACHEDLINK) IS "Y" AND
		IsDefined("GetEntry.ATTACHMENTCODE") AND
		GetEntry.ATTACHMENTCODE NEQ "")>
		<CFQUERY NAME="qryECINFORMSLINKATTACH" DATASOURCE=#client.company_dsn#>
			SELECT *
			FROM ECINFORMLINKATTACH
			WHERE ATTACHMENTCODE = '#GetEntry.ATTACHMENTCODE#'
		</CFQUERY>
	
		<CFIF qryECINFORMSLINKATTACH.RecordCount>
			<BR><br><CFIF IsDefined("url.view") OR IsDefined("url.print") OR IsDefined("url.route") OR IsDefined("url.isread")>
				<B><U>Link Attachments</U>:</B>
			<CFELSE>
				<B><U>Link Attachments (<i>check the box to remove Link</i>)</U>:</B>
			</CFIF>
			<BR>
			<CFOUTPUT QUERY="qryECINFORMSLINKATTACH">
				
				<!--- 	Disable link & checkbox if file not exist...
					...and hide checkbox if form is for viewing, printing or route only - winston --->
				<CFIF IsDefined("url.view") OR IsDefined("url.print") OR IsDefined("url.route") OR IsDefined("url.isread")>
						&nbsp;<IMG SRC="#client.icon_path#eformlink.gif">&nbsp;<A HREF="#LINKVALUE#" target="_blank" CLASS="regular11">#qryECINFORMSLINKATTACH.LINKNAME#</A>
				<CFELSE>
					&nbsp;&nbsp;<INPUT CLASS="regular11" TYPE="CheckBox" NAME="chkDelLinkAtt#CurrentRow#" VALUE="#qryECINFORMSLINKATTACH.LINKNAME#~#qryECINFORMSLINKATTACH.LINKVALUE#">
					&nbsp;<IMG SRC="#client.icon_path#eformlink.gif">&nbsp;<A HREF="#LINKVALUE#" target="_blank" CLASS="regular11">#qryECINFORMSLINKATTACH.LINKNAME#</A>
				</CFIF>	
			</CFOUTPUT>
		</CFIF>
	</CFIF>
</TD></CFIF>
	
	</TR>
</TABLE>
